package file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-10-02
 * Time: 16:32
 */
//通过Scanner获取文本文件中的数据
public class Demo8 {
    public static void main(String[] args) throws IOException {
        try(InputStream inputStream=new FileInputStream("D:/test.txt")){
            Scanner scanner=new Scanner(inputStream);
            //从test.txt文件中获取数据
            String s=scanner.next();
            System.out.println(s);
        }
    }
}
